#include "transform.h"


/*******************************************************
  Byte <-------------------> number transformation
********************************************************/
int changeByte2Integer(unsigned char msb,unsigned char lsb)
{
    int value;
    value = 0;
    value =((msb & 0x00FF)<<8) | lsb;

   return value; 
}

int changeByte2Int(unsigned char msb,unsigned char lsb)
{
    int val;
   
    val = 0x00;
    val = ((msb | val)<<8)|lsb;
    return val;
}

long changeByte2Long(unsigned char byte1,unsigned char byte2,unsigned char byte3,unsigned char byte4)
{
   value = 0;
   value = (((((((byte4|value)<<8)|byte3)<<8)|byte2)<<8)|byte1);
   return value;
}

unsigned char *changeLong2Byte(long DataVal)
{
   
  
   byte_array[0] = (DataVal & 0x000000FF);
   byte_array[1] = (DataVal & 0x0000FF00)>>8;
   byte_array[2] = (DataVal & 0x00FF0000)>>16;
   byte_array[3] = (DataVal & 0xFF000000)>>24;
  
   return byte_array;
}

unsigned char *changeInt2Byte(unsigned long data)
{
   

   byteDat[0] = (data & 0x000000FF);
   byteDat[1] = (data & 0x0000FF00)>>8;
   byteDat[2] = (data & 0x00FF0000)>>16;
   byteDat[3] = (data & 0xFF000000)>>24;
 

   return byteDat;
}
